package com.rx.base.demo.controller;

import com.rx.base.demo.common.BaseResult;
import com.rx.base.demo.entity.Label;
import com.rx.base.demo.model.LabelVo;
import com.rx.base.demo.service.impl.LabelServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(value = "label", tags = {"标签"})
@RestController
@RequestMapping("/label")
public class LabelController {
    @Autowired
    LabelServiceImpl labelService;

    @PostMapping("/")
    @ApiOperation(value = "create label", notes = "创建标签")
    public BaseResult<Label> createLabel(@RequestBody LabelVo labelVo) {
        // 数据库字段加唯一索引
        Label label = new Label();
        labelService.save(label);
        return BaseResult.success(label);
    }
}
